﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ENG.EngStartQueueLib
{
  [Serializable()]
  public class QueueSett
  {
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
    private ExecInfoCollection _Items = new ExecInfoCollection();
    ///<summary>
    /// Sets/gets Items value.
    ///</summary>
    public ExecInfoCollection Items
    {
      get
      {
        return (_Items);
      }
      set
      {
        _Items = value;
      }
    }

    public void Store(string fileName)
    {
      string tmp = System.IO.Path.GetTempFileName();

      System.Xml.Serialization.XmlSerializer ser =
        new System.Xml.Serialization.XmlSerializer(typeof(QueueSett));
      System.IO.Stream fs = new System.IO.FileStream(tmp, System.IO.FileMode.Open);
      ser.Serialize(fs, this);
      fs.Close();

      System.IO.File.Copy(
        tmp,
        fileName, true);
    }

    public static QueueSett Load(string fileName)
    {
      System.Xml.Serialization.XmlSerializer ser =
       new System.Xml.Serialization.XmlSerializer(typeof(QueueSett));
      System.IO.Stream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
      QueueSett ret = (QueueSett)ser.Deserialize(fs);
      fs.Close();

      return ret;
    }
  }
}
